﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Ooganizer.Platform
{
    public class AssemblyResolver
    {
        static public System.Reflection.Assembly Resolve(string assemblyName)
        {
            System.Reflection.Assembly assembly = null;

            string basePath = InstallationSpec.InstallPath;

            switch (assemblyName)
            {
                case "MSOfficeCloser":
                    assembly = Assembly.LoadFile(basePath + @"MSOfficeCloser.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;                
                case "WindowsCloser":
                    assembly = Assembly.LoadFile(basePath + @"WindowsCloser.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;                
                case "Closer":
                    assembly = Assembly.LoadFile(basePath + @"Closer.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;                
                case "CloserDispatch":
                    assembly = Assembly.LoadFile(basePath + @"CloserDispatch.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;
                case "ShellExecuteLauncher":
                    assembly = Assembly.LoadFile(basePath + @"ShellExecuteLauncher.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;
                case "Ooganizer.Client.UI.WorkspaceSelectorLib":
                    assembly = Assembly.LoadFile(basePath + @"Ooganizer.Client.UI.WorkspaceSelectorLib.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;
                case "Ooganizer.Server.OoganizerAPI":
                    assembly = Assembly.LoadFile(basePath + @"Server\Ooganizer.Server.OoganizerAPI.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;
                case "Ooganizer.Server.OoganizerServer":
                    assembly = Assembly.LoadFile(basePath + @"Server\Ooganizer.Server.OoganizerServer.dll", Assembly.GetExecutingAssembly().Evidence);
                    break;
                default:
                    break;
            }

            return assembly;
        }
    }
}
